/*
 * Copyright 2008-2023 dexian.vip. All rights reserved.
 * Support: http://www.dexian.vip
 * License: http://www.dexian.vip/license
 */

package vip.dexian.admin.command;

import vip.dexian.admin.enums.GenderEnum;
import vip.dexian.core.base.command.BaseCommand;
import vip.dexian.core.base.validation.group.Save;
import vip.dexian.core.base.validation.group.Update;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;

import java.io.Serial;
import java.util.List;

/**
 * 管理员添加 表单数据
 *
 * @author 挺好的 2023年06月05日 08:45:00
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode (callSuper = false)
public class AdminSaveCommand extends BaseCommand {

    @Serial
    private static final long serialVersionUID = -6134597211333608245L;

    /**
     * 姓名
     */
    @NotBlank (message = "姓名不能为空")
    @Length (message = "姓名的长度应在{min}和{max}个字符之间", min = 2, max = 20)
    @Pattern (message = "姓名只允许下划线和中文的组合", regexp = "^[_\u4e00-\u9fa5]+$")
    private String name;

    /**
     * 用户名
     */
    @NotBlank (message = "用户名不能为空", groups = {Save.class})
    @Length (message = "用户名的长度应在{min}和{max}个字符之间 ", groups = {Save.class}, min = 2, max = 20)
    @Pattern (message = "用户名只允许数字、英文、下划线、中文的组合", groups = {Save.class},
            regexp = "^[0-9a-zA-Z_\u4e00-\u9fa5]+$")
    private String username;

    /**
     * 手机号码
     */
    @NotBlank (message = "手机号码不能为空")
    @Length (message = "手机号码的长度应在{min}和{max}个字符之间 ", min = 11, max = 11)
    private String mobile;

    /**
     * 密码
     */
    @NotBlank (message = "密码不能为空", groups = {Save.class})
    @Length (message = "密码的长度应在{min}和{max}个字符之间", groups = {Save.class}, min = 6, max = 60)
    private String password;

    /**
     * 性别
     */
    @NotNull (message = "性别不能为空")
    private GenderEnum gender;

    /**
     * 头像
     */
    @Length (message = "头像的长度不可超过255个字符", max = 255)
    private String avatar;

    /**
     * 是否启用，1：是，0：否
     */
    @NotNull (message = "账户是否启用不能为空")
    private Boolean isEnabled;

    /**
     * 角色ID
     */
    @NotNull (message = "请选择角色", groups = {Save.class, Update.class})
    @Size (min = 1, message = "请至少选择{min}个角色", groups = {Save.class, Update.class})
    private List <Long> roleIds;

    /**
     * 部门
     */
    @NotNull (message = "部门不能为空")
    private Long departmentId;


}
